home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UTIL / PROGRAMMING / RINK010 / Demo / c / segment1 < prev    next >
Text File  |  1995-06-25  |  1KB  |  57 lines

  1. // rinkdemo - first segment
  2. // (c) Ben Summers 1995
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. // this next function definition would be in a header file in a real program
  8.  
  9. int FunctionInParentProgram(int Number);
  10.  
  11. // a defintion of a number in the parent. It would be defined in a header
  12. // file. Obviously, direct access of data is not to be encouraged, but
  13. // it is possible.
  14.  
  15. extern int NumberInParent;
  16.  
  17.  
  18. // some static data for this segment
  19.  
  20. int TheNumber;
  21.  
  22.  
  23.  
  24. int Start(char *String, int Number)
  25. {
  26.     printf("Start in segment 1, string = %s, number = %d\n\n", String, Number);
  27.  
  28.     TheNumber = Number;
  29.  
  30.     return TheNumber * 2;
  31. }
  32.  
  33. void Do(void)
  34. {
  35.     printf("Segment1 Do: number given at start = %d\n\n", TheNumber);
  36.  
  37.     // call a function in the main program
  38.     printf("... and it returned %d\n\n", FunctionInParentProgram(189));
  39. }
  40.  
  41. int Finish(int Number)
  42. {
  43.     return 0;
  44. }
  45.  
  46. void NamedEntry1(void)
  47. {
  48.     printf("Doubling number in parent\n");
  49.     NumberInParent*=2;
  50. }
  51.  
  52. void NamedEntry2(void)
  53. {
  54.     printf("NumberInParent = %d\n\n", NumberInParent);
  55. }
  56.  
  57.